﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Threading;

namespace JKDD.Doctor
{
    public partial class doctorApply : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            checkApply();
        }

        //验证
        private void checkApply()
        {
            string name = txtName.Text.ToString();
            string hospital = txtHospital.Text.ToString();
            string pass = txtPass.Text.ToString();
            string passAgain = txtPassAgain.Text.ToString();
            string email = txtEmail.Text.ToString();
            string title = txtTitle.Text.ToString();
            string doctorID = txtDoctorID.Text.ToString();
            string phone = txtFigure.Text.ToString();
            string mobile = txtMobile.Text.ToString();

            if (rbYes.Checked)
            {
                if (pass.Trim() != passAgain.Trim())
                {
                    lblError.Text = "密码不一致！";
                    txtPass.Text = "";
                    txtPassAgain.Text = "";
                }
                else
                {
                    if (name.Trim().Length > 0 && hospital.Trim().Length > 0 && pass.Trim().Length > 0 && email.Trim().Length > 0 && title.Trim().Length > 0 && phone.Trim().Length > 0 && mobile.Trim().Length > 0)
                    {
                        string sql = "insert into TB_DOCTOR_INFO(SPASS,SNAME,SMOBILE,SPHONE,SHOSPITAL,STITLE,SEMAIL) values('" + pass + "','" + name + "','" + mobile + "','" + phone + "','" + hospital + "','" + title + "','" + email + "')";

                        try
                        {
                            int result = operateDB.ExcuteSql(sql);
                            if (result > 0)
                            {
                                lblMessage.Text = "你的申请已提交，我们会认真核实你的身份！";
                            }
                            else
                            {
                                lblError.Text = "对不起，服务器正忙，请稍后再申请！";
                            }
                        }
                        catch (Exception ex)
                        {
                            lblError.Text = "对不起，提交失败，请稍后再申请！";
                        }
                    }
                    else
                    {
                        lblError.Text = "除介绍医生网号外，不能留空！";
                    }
                }
            }
            else
            {
                lblError.Text = "你不同意我们的服务条款，将无法申请！";
            }
        }
    }
}
